package com.project.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.EmployeeBean;
import com.project.mapper.IEmployeeMapper;
import com.project.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;

/**
 * @author lyl
 * description:员工业务层实现类
 */
@Service
@Transactional
public class EmployeeServiceImpl implements IEmployeeService {
    @Autowired
    private IEmployeeMapper iEmployeeMapper;


    @Override
    public void add(EmployeeBean employeeBean, int deptId) {
        iEmployeeMapper.add(employeeBean, deptId);
    }

    @Override
    public void del(int employeeId) {
        iEmployeeMapper.del(employeeId);
    }

    @Override
    public void update(int employeeId, int deptId, int money) {
        iEmployeeMapper.update(employeeId, deptId, money);
    }

    @Override
    public EmployeeBean findById(int employeeId) {
        return iEmployeeMapper.findById(employeeId);
    }

    @Override
    public PageInfo<EmployeeBean> findByPage(int pageNo, String employeeName, LocalDate startDate, LocalDate endDate) {
        PageHelper.startPage(pageNo, 3);
        PageInfo<EmployeeBean> info = PageInfo.of(iEmployeeMapper.findByPage(employeeName, startDate, endDate));
        return info;
    }
}
